/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package sessionbeans;

import entity.HashTag;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Axel
 */
@Stateless
public class HashTagFacade extends AbstractFacade<HashTag> {
    
    @PersistenceContext(unitName = "20121106_TwitterM2iPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public HashTagFacade() {
        super(HashTag.class);
    }

    public HashTag getByName(String name){
        HashTag ret = null;
        try{
            ret = (HashTag) em.createQuery("select h from HashTag h where h.label = :name")
        .setParameter("name", name)
        .getSingleResult();
        }catch(NoResultException e){
            //meh
        }
        return ret;
    }
}
